package cn.jr.service.impl;

import cn.jr.dao.IAccountDao;
import cn.jr.dao.impl.AccountDaoImpl;
import cn.jr.pojo.Account;
import cn.jr.service.IAccountService;

import java.util.ArrayList;

@SuppressWarnings("all")
public class AccountServiceImpl implements IAccountService {

    IAccountDao iad = new AccountDaoImpl();

    @Override //添加账户 -- accountId 不是自增，从tshoprun拿userId
    public boolean addAccount(int userId) {
        return iad.insertAccount(userId)>0?true:false;
    }

    @Override //更新余额 -- 拿 accountId 查找并给 accountMoney赋值
    public boolean changeMoneyInAccount(int accountId, double addedMoney) {
        return iad.updateAccount(accountId,addedMoney)>0?true:false;
    }

    @Override // 输入密码，查询账户总金额
    public ArrayList<Account> getAllAccount() {
        return iad.queryAccount();
    }
}
